Release 10.1A: OpenEdge Development:
ProDataSets
Using the SYNCHRONIZE method
The Data-Relation queries in a parent-child hierarchy are synchronized automatically only when there is a browse object attached to the query. This attachment is done by assigning the relation’s
QUERYattribute to the browse’sQUERYattribute. If you want to synchronize a hierarchy of queries under other circumstances, you use theSYNCHRONIZEmethod on any parent buffer handle:
This causes the ProDataSet to traverse the ProDataSet hierarchy starting at buffer
buffer-handle. It reopens each relation query for the current parent at each level, just as it happens automatically when you select a record in a browse or perform some 4GL action that changes the record position in a parent buffer whose children are attached to browses. The synchronize behavior is not provided automatically in all cases because there are simply too many different ways in which the position could be changed and too many different responses that a developer might want. Always reopening all related queries is not appropriate, because of the expense involved.You can decide when to synchronize by reacting to an event such as
ONVALUE-CHANGED, or simply in conjunction with a language statement or method such asGET-NEXT, and explicitly doing the synchronize when necessary. Note that this synchronization affects only the implicit dynamic queries associated with Data-Relations when you are navigating a ProDataSet that has already been filled. It has nothing to do with theFILLoperation itself, and using these queries is entirely optional. In many cases (perhaps even in most cases), your own 4GL logic will instead use conventional nestedFOR EACHblocks or queries to navigate through the levels of a ProDataSet, without using or caring about these implicit queries at all. This is part of why the overhead of opening them does not happen unless the relation queries have explicitly been attached to a browse.As part of the
SYNCHRONIZE()method, Progress automatically positions to the first row in each relation query in addition to reopening it on children of the current parent row. This is not done if the query is being browsed (with a 4GL client browse widget) because the browse effectively forces aGET-FIRSTalready.Doing this automatically spares the developer from having to write a
GET-FIRSTmethod on each child query. A typical block of code to navigate through the children of the current parent looks like this:
If you forget the
GET-FIRST, the loop exits immediately because the query is“OFF-END”if there’s no row at all in its buffer.In addition, this is the only way to propagate a
SYNCHRONIZE()through multiple parent-child levels. Consider the example of a three-level ProDataSet with tablesttCustomer,ttOrder, andttOrderLine. The application does aSYNCHRONIZE()on thettCustomertable when the user selects a different row in that table. Without doing an implicitGET-FIRSTon thettOrdertable to position it to the firstttOrderfor the newly selectedttCustomer, the relation query for thettOrderLinetable won’t be properly reopened and filtered forOrderLinesof theCustomer’sfirstOrder, because there would be no current row in thettOrdertable.Independent of all this, you can freely define queries of your own to navigate the tables in the ProDataSet after it has been filled, or even as part of custom code to populate one or more tables of a ProDataSet independent of its
FILLmethod.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |